﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace WeChatParking.Entity.Enums
{
    public enum carApiSaate
    {
        [Description("提交成功")]
        OK = 1000,
        [Description("提交失败：未知异常")]
        NO = 1001,
        [Description("提交失败：签名异常")]
        errSign = 1002,
        [Description("提交失败：类型异常")]
        errType = 1003,
        [Description("提交失败：时间戳异常")]
        errStamp = 1004,
        [Description("提交失败：空值异常")]
        errNull = 1005,
        [Description("提交失败：车场代码异常")]
        errCode = 1006
    }
    /// <summary>
    /// 审核类型
    /// </summary>
    public enum stateType
    {
        [Description("审核通过")]
        SHTG = 1,

        [Description("审核中")]
        SHZ = 0,

        [Description("审核拒绝")]
        SHJJ = -1
    }
    /// <summary>
    /// 支付类型
    /// </summary>
    public enum PayType
    {
        [Description("云闪付")]
        UnionPay = 5,
        [Description("微信支付")]
        Weixin = 6,

        [Description("支付宝支付")]
        Alipay = 7,

        [Description("通联支付")]
        Tonglian = 8,

        [Description("现金支付")]
        XJPay = 9,
    }

    /// <summary>
    /// 支付状态
    /// </summary>
    public enum PayStatus
    {
        /// <summary>
        /// 未支付
        /// </summary>
        [Description("未支付")]
        UnPay = 1,

        /// <summary>
        /// 部分支付
        /// </summary>
        [Description("部分支付")]
        Partial = 2,

        /// <summary>
        /// 支付完毕
        /// </summary>
        [Description("支付完毕")]
        Payed = 3
    }

    /// <summary>
    /// 订单状态
    /// </summary>
    public enum OrderStatus
    {
        /// <summary>
        /// 未支付
        /// </summary>
        [Description("未支付")]
        UnPay = 1,

        /// <summary>
        /// 进行中
        /// </summary>
        [Description("进行中")]
        Doing = 2,

        /// <summary>
        /// 已完成
        /// </summary>
        [Description("已完成")]
        Finish = 3,

        /// <summary>
        /// 已失效
        /// </summary>
        [Description("已失效")]
        Expire = 4,

        /// <summary>
        /// 已取消
        /// </summary>
        [Description("已取消")]
        Cancel = 5,
    }

    /// <summary>
    /// 订单写卡状态
    /// </summary>
    public enum OrderPoolStatus
    {
        /// <summary>
        /// 全部
        /// </summary>
        All = -1,

        /// <summary>
        /// 未写卡
        /// </summary>
        UnPool = 0,

        /// <summary>
        /// 已写卡
        /// </summary>
        Pooled = 1,

        /// <summary>
        /// 未缴费
        /// </summary>
        WXZJF = 2,

        /// <summary>
        /// 缴费成功
        /// </summary>
        XZJFCG = 3


    }

    /// <summary>
    /// 系统配置项
    /// </summary>
    public enum SystemConfig
    {
        /// <summary>
        /// 微信公众号AppID
        /// </summary>
        [Description("微信公众号AppID")]
        WxAppID = 101,

        /// <summary>
        /// 微信公众号Secret
        /// </summary>
        [Description("微信公众号Secret")]
        WxAppSecret = 102,

        /// <summary>
        /// 微信支付商户号
        /// </summary>
        [Description("微信支付商户号")]
        WxPayMchID = 103,

        /// <summary>
        /// 微信支付密钥
        /// </summary>
        [Description("微信支付密钥")]
        WxPayKey = 104,

        /// <summary>
        /// 微信支付通知地址
        /// </summary>
        [Description("微信支付通知地址")]
        WxPayNotifyUrl = 105,

        /// <summary>
        /// 微信获取用户code地址
        /// </summary>
        [Description("微信获取用户code地址")]
        WxGetCodeUrlFormat = 106,

        /// <summary>
        /// 微信获取openid地址
        /// </summary>
        [Description("微信获取openid地址")]
        WxGetOpenIDUrlFormat = 107,

        /// <summary>
        /// 微信获取用户地址
        /// </summary>
        [Description("微信获取用户地址")]
        WxGetUserInfoUrlFormat = 108,

        /// <summary>
        /// 微信JSAPI验证地址
        /// </summary>
        [Description("微信JSAPI验证地址")]
        WxJSApiTicketUrl = 109,

        /// <summary>
        /// 微信统一下单地址
        /// </summary>
        [Description("微信统一下单地址")]
        WxUnifiedOrderUrl = 110,

        /// <summary>
        /// 微信接口访问权限
        /// </summary>
        [Description("微信接口访问权限")]
        WxAccessTokenUrl = 111,
        /// <summary>
        /// 微信支付渠道
        /// </summary>
        [Description("微信支付渠道")]
        WxPayChannel,

        /// <summary>
        /// 是否企业微信
        /// </summary>
        [Description("是否企业微信")]
        IsQiyeWeixin = 204,

        /// <summary>
        /// 微信服务号发送模板消息接口地址
        /// </summary>
        [Description("微信服务号发送模板消息接口地址")]
        WxTemplatMsgUrl = 205,

        /// <summary>
        /// 微信企业号发送消息接口地址
        /// </summary>
        [Description("微信企业号发送消息接口地址")]
        WxQyhMsgUrl = 206,
        /// <summary>
        /// 通联支付AppID
        /// </summary>
        [Description("通联支付AppID")]
        TonglianAppId = 207,

        /// <summary>
        /// 是否使用智慧通行平台渠道
        /// </summary>
        [Description("是否使用智慧通行平台渠道")]
        IsUnionPay = 208,

        /// <summary>
        /// 应用商户代码，由智慧通行平台分配
        /// </summary>
        [Description("应用商户代码，由智慧通行平台分配")]
        UnionPayAppId = 209,
        /// <summary>
        /// 发起扣款请求的商户号
        /// </summary>
        [Description("发起扣款请求的商户号")]
        UnionPayIndustryCode = 210,
        /// <summary>
        /// 无感出行平台约定的密钥
        /// </summary>
        [Description("无感出行平台约定的密钥")]
        UnionPayKey = 211,
        /// <summary>
        /// 无感出行平台URL
        /// </summary>
        [Description("无感出行平台URL")]
        UnionPayUrl = 212,
        /// <summary>
        /// 支付完成后，智慧通行平台向此url推送支付结果
        /// </summary>
        [Description("支付完成后，智慧通行平台向此url推送支付结果")]
        UnionPayCallback = 213,
        /// <summary>
        /// 退款完成后，运营商接收退款结果通知的url
        /// </summary>
        [Description("退款完成后，运营商接收退款结果通知的url")]
        UnionPayRefundCallback = 214,
    }

    /// <summary>
    /// 登录用户类型
    /// </summary>
    public enum LoginUserType
    {
        /// <summary>
        /// 系统管理员
        /// </summary>
        SystemAdmin = 1,

        /// <summary>
        /// 企业管理员
        /// </summary>
        EnterpriseAdmin = 2,

        /// <summary>
        /// 企业用户（充值用户）
        /// </summary>
        EnterpriseUser = 3
    }

    /// <summary>
    /// 鉴权用户类型
    /// </summary>
    public enum OAuthUserType
    {
        /// <summary>
        /// 无
        /// </summary>
        None = 0,

        /// <summary>
        /// 微信服务号
        /// </summary>
        Wxfw = 1,

        /// <summary>
        /// 微信企业号
        /// </summary>
        Wxqy = 2
    }

    /// <summary>
    /// 日志类型
    /// </summary>
    public enum LogType
    {
        /// <summary>
        /// 管理平台登录
        /// </summary>
        AdminPlatLogin,

        /// <summary>
        /// 维护用户
        /// </summary>
        ManageUser,

        /// <summary>
        /// 维护企业
        /// </summary>
        ManageEnterprise,

        /// <summary>
        /// 更改密码
        /// </summary>
        ChangePassword,

        /// <summary>
        /// 创建订单
        /// </summary>
        CreateOrder,

        /// <summary>
        /// 接口调用
        /// </summary>
        Api,
        /// <summary>
        /// 微信通知消息
        /// </summary>
        WxNotifyMsg,
        /// <summary>
        /// 服务_进场
        /// </summary>
        Server_In,
        /// <summary>
        /// 服务_出场
        /// </summary>
        Server_Out,
        /// <summary>
        /// 服务_费率
        /// </summary>
        Server_PayFeeType,
        /// <summary>
        /// 服务_现场缴费
        /// </summary>
        Server_XCPay,
        UnionPay_In,
        UnionPay_Out,
        UnionPay_carStatus,
    }

    public enum MsgSendState
    {
        /// <summary>
        /// 待发送
        /// </summary>
        Waiting = 0,

        /// <summary>
        /// 发送失败
        /// </summary>
        Fali = 1,

        /// <summary>
        /// 发送成功
        /// </summary>
        Success = 2
    }

    /// <summary>
    /// 状态码
    /// </summary>
    public enum State
    {
        /// <summary>
        /// 成功
        /// </summary>
        [Description("成功")]
        OK = 0,
        /// <summary>
        /// 提交失败：功能号异常
        /// </summary>
        [Description("提交失败：功能号异常")]
        errFunc_no = 1,
        /// <summary>
        /// 提交失败：签名异常
        /// </summary>
        [Description("提交失败：签名异常")]
        errSign = 2,
        /// <summary>
        /// 提交失败：数据异常
        /// </summary>
        [Description("提交失败：数据异常")]
        errData = 3,
        /// <summary>
        /// 提交失败：图片异常
        /// </summary>
        [Description("提交失败：图片异常")]
        errImg = 4,
        /// <summary>
        /// 提交失败：金额异常
        /// </summary>
        [Description("提交失败：金额异常")]
        errFee = 5,
        /// <summary>
        /// 提交失败：时间异常
        /// </summary>
        [Description("提交失败：时间异常")]
        errTime = 6,
        /// <summary>
        /// 提交失败：车牌异常
        /// </summary>
        [Description("提交失败：车牌异常")]
        errCar = 7,
        /// <summary>
        /// 提交失败：客户端代码异常
        /// </summary>
        [Description("提交失败：客户端代码异常")]
        errCode = 8,
        /// <summary>
        /// 提交失败：未知异常
        /// </summary>
        [Description("提交失败：未知异常")]
        errNo = 9
    }
    /// <summary>
    /// 功能号
    /// </summary>
    public enum Func_no
    {
        /// <summary>
        /// 网络连接状态心跳包
        /// </summary>
        [Description("网络连接状态心跳包")]
        Heartbeat = 1,
        /// <summary>
        /// 进出场数据上传
        /// </summary>
        [Description("进出场数据上传")]
        inOrOut = 2,
        /// <summary>
        /// 预缴费
        /// </summary>
        [Description("预缴费")]
        YPay = 3,
        /// <summary>
        /// 现场缴费
        /// </summary>
        [Description("现场缴费")]
        XCPay = 4,
        /// <summary>
        /// 费用查询(服务主动)
        /// </summary>
        [Description("费用查询")]
        FeeQuery = 5,
        /// <summary>
        /// 月租缴费查询(服务主动)
        /// </summary>
        [Description("月租缴费查询")]
        MonthFeeQuery=6

    }
    /// <summary>
    /// 枚举值帮助类
    /// </summary>
    public static class EnumsHelper
    {
        /// <summary>
        /// 获取枚举值说明信息
        /// </summary>
        /// <param name="value">枚举值</param>
        /// <returns></returns>
        public static string GetDescription(Enum value)
        {
            Type enumType = value.GetType();
            // 获取枚举常数名称。
            string name = Enum.GetName(enumType, value);
            if (name != null)
            {
                // 获取枚举字段。
                System.Reflection.FieldInfo fieldInfo = enumType.GetField(name);
                if (fieldInfo != null)
                {
                    // 获取描述的属性。
                    DescriptionAttribute attr = Attribute.GetCustomAttribute(fieldInfo,
                        typeof(DescriptionAttribute), false) as DescriptionAttribute;
                    if (attr != null)
                    {
                        return attr.Description;
                    }
                }
            }
            return null;
        }

        /// <summary>
        /// 获取枚举值的常数名称
        /// </summary>
        /// <param name="value">枚举值</param>
        /// <returns></returns>
        public static string GetEnumName(Enum value)
        {
            Type enumType = value.GetType();
            string name = Enum.GetName(enumType, value);
            return name;
        }

        /// <summary>
        /// 解析泛型值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="enumName"></param>
        /// <returns></returns>
        public static T Parse<T>(string enumName) where T : struct
        {
            T val;
            Enum.TryParse<T>(enumName, out val);
            return val;
        }


    }
}
